<?php 



	function fta_simpleMailerSendTemplateWithValues($recipients,$bccRecipients,$from,$subject, $template,$values=null){
		$template = file_get_contents($template);
		fta_simpleMailerSendMessageWithValues($recipients, $bccRecipients, $from, $subject, $template, $values);							
	}
	
	
	function fta_simpleMailerSendMessageWithValues($recipients,$bccRecipients,$from,$subject, $template,$values=null){
		
		//now do the search and replace on the patterns
		$emailHtml = str_replace(array_map(function($item){ return "[".$item."]";},array_keys($values)),array_values($values),$template);
	
		$mail = new Zend_Mail();
		
		//this makes use of what is known as the fluent interface.. LOOK UP WHAT IT MEANS.. you need to check the docs
		// to see if an object supports it or not.. 
		// really, there should just be a static factory on the Zend_mail then it would be easy
		// not sure if i like this as it could lead to muck.. but we will leave it for now as it works
		// and i wanted to see what would happen
		$mail->setBodyHtml($emailHtml)->setFrom($from)->addTo($recipients)->addBcc($bccRecipients)->setSubject($subject)->send();		
	}